package com.zou.music_downloader.sqlite;

import android.content.Context;
import android.database.DatabaseErrorHandler;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.provider.SyncStateContract;

import com.zou.music_downloader.Constants;

/**
 * Created by zou on 2016/3/14.
 */
public class MySqliteOpenHelper extends SQLiteOpenHelper {
    public MySqliteOpenHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
        super(context, name, factory, version);
    }

    public MySqliteOpenHelper(Context context) {
        super(context, Constants.tableName, null, 1);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
//        Downloadid，Songid,下载时间 ，文件路径，歌名，作者，状态（下载中，下载完）
        String sql = "create table if not exists " + Constants.tableName + " (DownloadId long primary key, SongId String,DownloadTime long, Path String, SongName String, AuthorName String,State String )";
        db.execSQL(sql);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        String sql = "DROP TABLE IF EXISTS " + Constants.tableName;
        db.execSQL(sql);
        onCreate(db);
    }
}
